package com.touni.designpattern.prototypepattern;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @ClassName : ShapeTable
 * @Description :
 * @Author : lwq
 * @Date: 2020-10-20 19:31
 */
public class ShapeTable {
    public static Map<String,Shape> shapeMap = new ConcurrentHashMap<>();

    public static Shape getShapeFromTable(String shapeName){
        Shape shape = shapeMap.get(shapeName);
        return shape.clone();
    }

    public static void initShapeMap(){
        Shape circle = new Circle();
        shapeMap.put("circle",circle);
        Shape trapezoid = new Trapezoid();
        shapeMap.put("trapezoid",trapezoid);
    }

}
